using System;

namespace Medianamik.UI.Web.MVP
{
    [Flags]
    public enum ModuleViewFilters
    {
        None = 0x0,
        StartDate = 0x1,
        EndDate = 0x2,
        Keywords = 0x4,
        Status = 0x8,
        All = StartDate | EndDate | Keywords | Status
    }

    public static class Extensions
    {
        public static bool HasFilter(this ModuleViewFilters op, ModuleViewFilters checkflag)
        {
            return (op & checkflag) == checkflag;
        }

        public static bool HasAllFiters(this ModuleViewFilters op, params ModuleViewFilters[] checkflags)
        {
            foreach (var checkflag in checkflags)
            {
                if ((op & checkflag) != checkflag)
                    return false;
            }

            return true;
        }
    }
}